<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<title>添加类型</title>
		<link href="css/table.css" rel="stylesheet" type="text/css" />
		<script type="text/javascript" src="js/jquery-1.4.2.min.js"></script>
		<script type="text/javascript">
			function selectOrg(val){
				var url="orgByFlow.action?status="+val;
				openWindow(url,650,550);
			}
			function setValue(value,val){
				  var arr = eval(value);
				  var names = "";
				  var ids = "";
				  for(i=0;i<arr.length;i++){
				    ids =  ids + "," + arr[i].value;
				    names = names + "," + arr[i].name;
				  }
				  if(names.length>0){
				    names = names.substring(1);
				    ids =  ids.substring(1);
				  }
				  document.getElementById(val+"names").value=names;
				  document.getElementById(val+"ids").value=ids;
			}
			function getOldValue(val){
				  var ids=document.getElementById(val+"ids").value;
				  var names=document.getElementById(val+"names").value;
				    var array="";
				  if(ids!=''&&ids!='null'){
				  var idarray=ids.split(",");
				  var namearray=names.split(",");
				  for(var i=0;i<idarray.length;i++){
				  		if(i==0){
				  			array+="{\"value\":"+idarray[i]+",\"name\":\""+namearray[i]+"\"}";
				  		}else{
				  	      array+=",{\"value\":"+idarray[i]+",\"name\":\""+namearray[i]+"\"}";
				  	   } 
				  }
				  }
				  return array;
			}
			
			function saveType(){
				var name = $("#onames").val();
				var type=$("#type").val();
				if($.trim(name)==''||$.trim(name)=='null'){
					alert("适用范围不能为空！");return;
				}
				if($.trim(type)==''||$.trim(type)=='null'){
					alert("类型名称不能为空！");return;
				}
				$.post("typeAddSave.action",$("form").serialize(),function(data){
					if(data=='success'){
						alert("操作成功！");
						window.close();
						window.opener.location.href="typeSet.action";
					}else{
						alert("操作失败！");
					}
				});
			}
		</script>
		<script type="text/javascript" src="js/openwindow.js"></script>
	</head>

	<body>
		<table align="center" border="0" cellpadding="0" cellspacing="0" style="width: 98%;">
			<tbody>
				<tr>
					<td style="background: url('image/wsoa_window_002.gif');" width="1"></td>
					<td style="background: url('image/wsoa_window_002.gif');">
						<table border="0" cellpadding="0" cellspacing="0">
							<tbody>
								<tr>
									<td align="center"
										style="background: url('image/wsoa_window_002.gif');"
										width="10">
										<img src="image/center_19.gif">
									</td>
									<td align="center"
										style="background: url('image/wsoa_window_002.gif');"></td>
									<td>
										公文管理 &gt; 收文管理 &gt; 类型设置 &gt;
										<a href="typeAdd.action">添加</a>
									</td>
								</tr>
							</tbody>
						</table>
					</td>
					<td style="background: url('image/wsoa_window_002.gif');" width="1"></td>
				</tr>
				<tr>
					<td style="background: url('image/wsoa_window_010.gif');" width="1">
						&nbsp;
					</td>
					<td>

						<form action="" name="typeForm" method="post">
							<input type="hidden" name="typeSet.id" value="${typeSet.id }">
							<input type="hidden" name="typeSet.createTime" value="${typeSet.createTime }">
							<input type="hidden" name="typeSet.del" value="${typeSet.del }">
							<table align="center" class="table5" frame="box" style="margin-top: 10px">
								<tr>
									<td class="table5 bgcolor5" width="60px">
										类型名称
									</td>
									<td class="table5">
										<input id="type" type="text" width="200px" name="typeSet.name" onkeydown="valid()"
											value="${typeSet.name }">
									</td>
								</tr>
								<tr>
									<td class="table5 bgcolor5" width="60px">
										适用范围
									</td>
									<td class="table5">
										<textarea readonly="readonly" id="onames"
											style="height: 30px; width: 400px; "
											name="typeSet.departmentNames">${typeSet.departmentNames }</textarea>
										<input type="hidden" id="oids" name="typeSet.departmentIds"
											value="${typeSet.departmentIds}">
										<br><a href="javascript:selectOrg('o')">选择部门</a>
									</td>
								</tr>
								<tr>
									<td colspan="2" align="center">
									<input class="button_04" onclick="saveType()" type="button" value="确定" />
								&nbsp;&nbsp;
								<input class="button_04" type="button" onclick="exit()" value="取消" />
									</td>
								</tr>
							</table>
						</form>
					</td>
					<td style="background: url('image/wsoa_window_006.gif');" width="1">
						&nbsp;
					</td>
				</tr>
				<tr>
					<td height="1" width="1">
						<img src="image/wsoa_window_009.gif" height="16" width="14">
					</td>
					<td style="background: url('image/wsoa_window_008.gif');"
						height="1"></td>
					<td height="1" width="1">
						<img src="image/wsoa_window_007.gif" height="16" width="12">
					</td>
				</tr>
			</tbody>
		</table>
	</body>
</html>